package com.donghaiair.framework.common.util;

import java.security.MessageDigest;

/**
 * 类名:MD5Util.java
 * 说明:
 */
public class MD5Util {

    public final static String MD5(String s) {
        try {
            byte[] btInput = s.getBytes();
            MessageDigest mdInst = MessageDigest.getInstance("MD5");
            mdInst.update(btInput);
            byte[] md = mdInst.digest();
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < md.length; i++) {
                int val = ((int) md[i]) & 0xff;
                if (val < 16)
                    sb.append("0");
                sb.append(Integer.toHexString(val));
            }

            return sb.toString();
        } catch (Exception e) {
            return null;
        }
    }


    public static void main(String[] a) {
        System.out.println(MD5("5201314"+"5F1D7A84DB00D2FCE00B31A7FC73224F"));
        
        System.out.println(UpperAndLower.lowerToUpper(MD5Util.MD5(MD5Util.MD5("123456") + "123456")));
    }

}
